﻿using AutoMapper.Configuration;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using taigu.WeChat;
using Volo.Abp.Application.Services;
using Volo.Abp.Domain.Repositories;

namespace taigu
{
    public class PostLikeService : ApplicationService, IPostLikeService
    {
        private readonly IRepository<WeChat.PostLike, Guid> _repository;
        public PostLikeService(IRepository<WeChat.PostLike, Guid> repository, IConfiguration configuration)
        {
            this._configuration = configuration;
            this._repository = repository;
        }
        private IConfiguration _configuration;

        ///// <summary>
        ///// 点赞，取消点赞
        ///// </summary>
        ///// <param name="postLikeDto"></param>
        ///// <returns></returns>
        // [AllowAnonymous]
        //[Route("/community/createLike"), HttpPost]
        //public async Task<ResData<string>> CreateAsync(PostLikeDto postLikeDto)
        //{
        //    try
        //    {
        //        PostLike postLike = await _repository.GetAsync(x => x.user_id == postLikeDto.user_id && x.post_id == postLikeDto.post_id);
        //        if (postLike == null)
        //        {
        //            PostLike data = ObjectMapper.Map<PostLikeDto, PostLike>(postLikeDto);
        //            data.status = PostStatus.启用;
        //            var result = await _repository.InsertAsync(data);
        //            return new ResData<string>() { Status = ResStatus.成功, Msg = "sucess", Info = "" };
        //        }
        //        else
        //        {
        //            postLike.status = PostStatus.禁用;
        //            await _repository.UpdateAsync(postLike);
        //            return new ResData<string>() { Status = ResStatus.成功, Msg = "sucess", Info = "" };
        //        }
        //    }
        //    catch
        //    {
        //        return new ResData<string>() { Status = ResStatus.failed, Msg = "sucess", Info = "" };
        //    }
        //}
        [AllowAnonymous]
        [Route("/community/Test"), HttpGet]
        public Task<ResData<string>> Test(string postLikeDto)
        {
            throw new NotImplementedException();
        }

        public Task<ResData<string>> CreateAsync(PostLikeDto postLikeDto)
        {
            throw new NotImplementedException();
        }
    }
}
